package com.hk.web.controller.pc;

import com.hk.Mgr.web.message.StatusCode;
import com.hk.base.BaseCtrl;
import com.hk.base.ResponseBase;
import com.hk.commons.ReqToModelHelper;
import com.hk.commons.entity.Activity;
import com.hk.commons.vo.ActivityRes;
import com.hk.service.kyc.IActivity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping(value = BaseCtrl.PC + "/activityCtrl")
public class pcActivityCtrl extends BaseCtrl {

	@Autowired
	private IActivity activityService;

	/**
	 * 获得所有订单信息
	 * 
	 * @author jeff
	 * @return
	 */
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	@ResponseBody
	public ResponseBase<List<ActivityRes>> listOrder(@RequestParam Integer channel) {

		if(channel == null || channel == 0 ){
			channel = 3;
		}

		ResponseBase<List<ActivityRes>> resp = new ResponseBase<>();
		List<ActivityRes> actReslist = new ArrayList<>();
		List<Activity> list = activityService.getActiveActivity();
		
		for (Activity ag : list) {
			ActivityRes activityRes = new ActivityRes();
			ReqToModelHelper.copyReqValueToModel(ag, activityRes);
			actReslist.add(activityRes);
			resp.setResult(actReslist);
			resp.setSize(actReslist.size());
		}
		resp.setResult(actReslist);
		resp.setResultCode(StatusCode.SUCCESS.key());
		return resp;
	}
}
